import plotly.express as px
from csv_sif import parse_csv as csv
import pandas as pd

def fun():

    readable_data = csv.ParseCsv("/json_sif/file/world_fires_1_day.csv")
    datas = readable_data.query_columns(["longitude","latitude","brightness"])

    lons, lats, brightness = [],[],[]
    for data in datas:
        lons.append(float(data['longitude']))
        lats.append(float(data['latitude']))
        brightness.append(float(data['brightness']))
    data = pd.DataFrame(
        data=zip(lons, lats, brightness),
        columns=["经度", "维度", "火灾强度"]
    )

    fig = px.scatter(
        data,
        x="经度",
        y="维度",
        range_x=[-200, 200],
        range_y=[-90, 90],
        width=800,
        height=800,
        title="全国火灾分布图",
        size="火灾强度",
        size_max=10,
        color="火灾强度"
        # color_continuous_scale=px.colors.diverging.RdYlGn[::-1]
    )

    fig.write_html("fires.html")
    fig.show()